﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Net;
using System.Windows;
using System.Windows.Controls;
using System.Windows.Documents;
using System.Windows.Input;
using System.Windows.Media;
using System.Windows.Media.Animation;
using System.Windows.Shapes;
using Skyper.Model;

namespace Skyper.View.Panorama {
	public partial class ContactsView : UserControl {
		#region Fields
		private Object activeContact;
		#endregion
		#region Constructor
		public ContactsView() {
			InitializeComponent();
		}
		#endregion
		#region Private
		private void Button_Click(object sender, RoutedEventArgs e) {
			Button button = (sender as Button);

			if (button != null) {
				ContactModel mod = button.DataContext as ContactModel;

				if (mod != null) {
					App.OpenChat(mod);
				}
			}
		}
		private void Contact_MouseLeftButtonDown(object sender, MouseButtonEventArgs e) {
			activeContact = sender;
		}
		private void Contact_MouseLeftButtonUp(object sender, MouseButtonEventArgs e) {
			if (activeContact == sender) {
				FrameworkElement node = (sender as FrameworkElement);

				if (node == null) {
					return;
				}
				ContactModel contact = node.DataContext as ContactModel;
				if (contact == null) {
					return;
				}
				App.OpenChat(contact);
			}
			activeContact = null;
		}
		private void Contact_MouseLeave(object sender, MouseEventArgs e) {
			activeContact = null;
		}
		#endregion
	}
}
